package com.foreknow.springboot_demo.controller;

import com.foreknow.springboot_demo.po.Business;
import com.foreknow.springboot_demo.service.BusinessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

//@Controller
/*@RestController 这个注解相当于@@Controller+  @ResponseBody*/
//面试题使用SpringBoot中的@RestController注解有什么好处？
@RestController
@RequestMapping("/BusinessController")
public class BusinessController {

    @Autowired
    private BusinessService businessService;

    /**
     * 可以使用Business对象来接受前台的请求参数
     * 无需再写request.getParameter()
     * @param business
     * @return
     */
//    @ResponseBody
    @RequestMapping("/listBusinessByOrderTypeId")
    public List<Business> listBusinessByOrderTypeId(Business business){
        return businessService.listBusinessByOrderTypeId(business.getOrderTypeId());
    }

//    @ResponseBody
    @RequestMapping("/getBusinessById")
    public Business getBusinessById(Business business){
        return businessService.getBusinessById(business.getBusinessId());
    }


}
